package com.zh.freechat.common.resp;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.zh.freechat.domain.user.entity.ChatUser;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author ZH
 * @date 12:18 2022/2/17
 */
@Getter
@Setter
public class ChatRelationDTO implements Serializable {
    /**
     * 主键ID
     */
    private String relId;
    /**
     * 自己的userId
     */
    private String userId;
    /**
     * 对方聊天者的 是否在线
     */
    private Boolean isOnline;
    /**
     * 对方聊天者的 是否是好友
     */
    private Boolean isFriend;

    private ChatUser chatUser;

    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime lastTime;

    private ChatRelationDTO(){}

    public ChatRelationDTO(String relId, String userId, ChatUser chatUser) {
        this.relId = relId;
        this.userId = userId;
        this.chatUser = chatUser;
    }

    public String getChatterId() {
        return chatUser.getUid();
    }
}
